<?php
/**
 * DCRM Mobile Page
 *
 * This file is part of WEIPDCRM.
 * 
 * WEIPDCRM is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WEIPDCRM is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with WEIPDCRM.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once('system/common.inc.php');

base_url();

// URL For Rewrite 
$rewrite_mod = get_option('rewrite_mod');
switch($rewrite_mod){
	case 3:
		$rewrite_url = array('view' => 'view/%d', 'view_nohistory' => 'view/%d/nohistory', 'screenshot' => 'screenshot/%d', 'history' => 'history/%d', 'contact' => 'contact/%d', 'section' => 'section/%d', 'report' => 'report/%d', 'report_support' => 'report/%1$d/%2$d', 'more' => 'more/%d', 'more_offset' => 'more/%1$d/%2$d', 'misc' => 'misc');
		break;
	case 1:
	case 2:
	default:
		$rewrite_url = array('view' => 'index.php?method=view&amp;pid=%d', 'view_nohistory' => 'index.php?pid=%d&amp;addr=nohistory', 'screenshot' => 'index.php?method=screenshot&amp;pid=%d', 'history' => 'index.php?method=history&amp;pid=%d', 'contact' => 'index.php?method=contact&amp;pid=%d', 'section' => 'index.php?method=section&amp;pid=%d', 'report' => 'index.php?method=report&amp;pid=%d', 'report_support' => 'index.php?method=report&amp;pid=%1$d&amp;support=%2$d', 'more' => 'index.php?method=more&amp;pid=%d', 'more_offset' => 'index.php?method=more&amp;pid=%1$d&amp;offset=%2$d', 'misc' => 'misc.php');
		break;
}
function echo_rewrite_url($type, $variable1, $variable2=''){
	global $rewrite_url;
	echo SITE_URL;
	printf($rewrite_url[$type], $variable1, $variable2);
}

class_loader('Mobile_Detect');
$detect = new Mobile_Detect;
if(!$detect->isiOS()){
	if (DCRM_PCINDEX == 1) {
		header("Location: ".SITE_URL."User.php");
		exit();
	} else {
		$isCydia = false;
	}
} else {
	if (DCRM_MOBILE == 2) {
		if (!strpos($detect->getUserAgent(), 'Cydia')) {
			$isCydia = false;
		} else {
			$isCydia = true;
		}
	} else {
		exit('Access Denied');
	}
}
if (file_exists('Release')) {
	$release = file('Release');
	$release_origin = __('No Name');
	$release_mtime = filemtime('Release');
	$release_time = date('Y-m-d H:i:s',$release_mtime);
	foreach ($release as $line) {
		if(preg_match('#^Origin#', $line)) {
			$release_origin = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
		if(preg_match("#^Description#", $line)) {
			$release_description = trim(preg_replace("#^(.+):\\s*(.+)#","$2", $line));
		}
	}
} else {
	$release_origin = __('Empty Page');
}
if (isset($_GET['pid'])) {
	if (ctype_digit($_GET['pid']) && intval($_GET['pid']) <= 10000) {
		function device_check(){
			global $detect;
			$device_type = array('iPhone', 'iPod', 'iPad');
			for ($i = 0; $i < count($device_type); $i++) {
				$check = $detect->version($device_type[$i]);
				if ($check !== false) {
					if (isset($_SERVER['HTTP_X_MACHINE'])) {
						$DEVICE = $_SERVER['HTTP_X_MACHINE'];
					} else {
						$DEVICE = 'Unknown';
					}
					$OS = str_replace('_', '.', $check);
					break;
				}
			}
			return array('DEVICE' => $DEVICE, 'OS' => $OS);
		}

		if (isset($_GET['method']) && $_GET['method'] == 'screenshot') {
			$index = 2;
			$title = __('View Screenshots');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'report') {
			$device_info = device_check();
			if (!isset($_GET['support'])) {
				$index = 3;
			} else {
				if ($_GET['support'] == '1') {
					$support = 1;
				} elseif ($_GET['support'] == '2') {
					$support = 2;
				} elseif ($_GET['support'] == '3') {
					$support = 3;
				} else {
					$support = 0;
				}
				$index = 4;
			}
			$title = __('Report Problems');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'history') {
			$index = 5;
			$title = __('Version History');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'contact') {
			$index = 6;
			$title = __('Contact us');
		} elseif (isset($_GET['method']) && $_GET['method'] == 'pcsection') {
			$index = 7;
          $section = DB::fetch_first("SELECT `Name`, `Icon` FROM `".DCRM_CON_PREFIX."Sections` WHERE `ID` = '".(int)$_GET['pid']."'");
			$title = __(DB::real_escape_string($section['Name']));
		} elseif (isset($_GET['method']) && $_GET['method'] == 'more') {
			$index = 8;
			$section = DB::fetch_first("SELECT `Name`, `Icon` FROM `".DCRM_CON_PREFIX."Sections` WHERE `ID` = '".(int)$_GET['pid']."'");
			$q_name = DB::real_escape_string($section['Name']);
			if (isset($_GET['offset']) && !empty($_GET['offset']) && ctype_digit($_GET['offset'])) {
				$offset = intval($_GET['offset']);
			} else {
				$offset = 0;
			}
			$packages = DB::fetch_all("SELECT `ID`, `Name`, `Package` FROM `".DCRM_CON_PREFIX."Packages` WHERE (`Stat` = '1' AND `Section` = '".$q_name."') ORDER BY `ID` DESC LIMIT 10 OFFSET ".$offset);
			foreach($packages as $package){
				if(!empty($package)){
					if ($isCydia) { ?>
				<a href="cydia://package/<?php echo($package['Package']); ?>" target="_blank">
<?php					} else { ?>
				<li>
	<a href="<?php echo_rewrite_url('pc', $package['ID']);?>" class="app_icon" >
<?php					} ?>
	
    
<div class="desc" ><?php echo ($package['Description']);  ?></div>
</li>
<?php
				}
			}
			exit();
		} elseif (!isset($_GET['method']) || (isset($_GET['method']) && $_GET['method'] == 'public')) {
			$index = 1;
			$title = __('View Package');
			$package_id = (int)DB::real_escape_string($_GET['pid']);
			$package_info = DB::fetch_first("SELECT `Name`, `Version`, `Author`, `Package`, `Description`, `DownloadTimes`, `Multi`, `CreateStamp`, `Size`, `Installed-Size`, `Section`, `Homepage`, `Tag`, `Level`, `Price`, `Purchase_Link`, `Changelog`, `Changelog_Older_Shows`, `Video_Preview`, `System_Support`, `ScreenShots` FROM `".DCRM_CON_PREFIX."Packages` WHERE `ID` = '".$package_id."' LIMIT 1");
			if ($package_info) $title = $package_info['Name'];
		} else {
			httpinfo(405);
			exit();
		}
	} else {
		httpinfo(405);
		exit();
	}
} elseif (!isset($_GET['method'])) {
	$index = 0;
	$title = $release_origin;
} else {
	httpinfo(405);
	exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>会员个人中心</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="apple-mobile-web-app-title" content="<?php echo($release_origin); ?>" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="HandheldFriendly" content="true" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="robots" content="index, follow" />
		<link rel="stylesheet" href="./Cydia/menes2.min.css">
      <link rel="stylesheet" href="<?php echo(SITE_URL); ?>/ziyuan/boot.css">
		<link rel="stylesheet" href="./Cydia/scroll2.min.css">     
		<script src="./Cydia/user/fastclick.js" type="text/javascript"></script>
		<script src="./Cydia/user/menes.js" type="text/javascript"></script>
		<script src="./Cydia/user/cytyle.js" type="text/javascript"></script><!--<base target="_top">--><base href="." target="_top"><style type="text/css"> p, input[type="password"], input[type="text"], select { top: 0.051470588235294115em; } </style>
		<script src="./Cydia/user/jquery.min.js"></script>
      <link rel="stylesheet" href="200.css" media="all">
<script src="ziyuan/js/udidtj.js"></script>
<script> 
jQuery(document).ready(function($) {
	$('.theme-login').click(function(){
		$('.theme-popover-mask').fadeIn(100);
		$('.theme-popover').slideDown(200);
	})
	$('.theme-poptit .close').click(function(){
		$('.theme-popover-mask').fadeOut(100);
		$('.theme-popover').slideUp(200);
	})
 
})
</script>
 <?php
if (defined("AUTOFILL_SEO")) {
?>
		<meta name="title" content="<?php echo(AUTOFILL_SEO); ?>" />
<?php
}
if (!empty($release_description)) {
?>
		<meta name="description" content="<?php echo($title); ?> ™| 最简洁的中文源，简单整洁有序的Cydia源，提供实用的DEB包。" />
<?php
}
if (defined("AUTOFILL_KEYWORDS")) {
?>
		<meta name ="keywords" content="<?php echo(AUTOFILL_KEYWORDS); ?>" />
<?php
}
if ($isCydia) {
?>
		<base target="_blank">
<?php
} else {
?>
		<base target="_top">
<?php
}
?>  

</head>
	<body class="pinstripe">
            <panel>
     <div style="height:2px;width:100%">
        <div style="background-color:red;height:2px;width:0" id="progress"></div>
    </div>
    <panel class="left">
        <div style="margin:9px;padding:0 16px">
            <style type="text/css">
                .cytyle-flat #logo {
                    background-image: url("./CydiaIcon.png");
                    background-size: 58px 58px;
                    width: 58px
                }
            </style>        
            <div id="logo" style="position:absolute;display:inline-block;height:58px;vertical-align:middle" alt="Cydia Logo"></div>
            <p style="padding-top:8px;margin-left:70px;text-align:center;display:block;height:60px;text-rendering:optimizeLegibility">
            <span style="font-size:18px">欢迎使用 Cydia 帐户<sup>™</sup></span><br>
            <span style="font-size:14px"><a>会员个人管理中心</a></span><br>
            <span style="font-size:14px"><a>Build by mycydia.vip</a></span></p>
        </div>

<?php
require_once 'qqlogin/function.php';
require_once 'qqlogin/Connect2.1/qqConnectAPI.php';
?>     
 
<?php if(!isset($_SESSION['accesstoken']) || !isset($_SESSION['openid'])) { ?>
     <block class="box1" style="background-color: #FFFFFF;">
        <p style="color: #303130; font-size:14px;">登录账号用来启用收藏插件功能,您可在不同的设备上登录同一个账号来快速安装收藏过的插件！</p>
    </block>
      <fieldset class="box">
                  <a href="./qqlogin/qqlogin.php" target="_self"> 
                        <img class="icon" src="./icon/default/qqlogin.png">
                            <div>
                                <div>
                                    <label>
                                        <p>使用 QQ 授权登录</p>
                                    </label>
                                </div>
                            </div>
                  </a>
        </fieldset>
<?php } else { 
   
$qc = new QC($_SESSION['accesstoken'],$_SESSION['openid']);
$arr = $qc->get_user_info();
             
?>
<?php
	$num = DB::result_first("SELECT count(*) FROM `".DCRM_CON_PREFIX."Worklist` WHERE `UserOpenID`='".$_SESSION['openid']."'");
?>      
     <block class="box1" style="background-color: #FFFFFF;">
        <p style="color: #303130; font-size:14px;">启用收藏插件功能,您可在不同的设备上登录同一个账号来快速安装收藏过的插件！</p>
       <hr>
       <p>您已提交 <strong><?php echo $num ?></strong> 个工单</p>
    </block>
   


    		<fieldset class="box">
                  <a>
                        <img class="icon" src="<?php echo $arr['figureurl_qq_2'];?>" style="border-radius: 50%;box-shadow:0 0 1px #AAA;padding:1px;margin-right: 1px;">
                            <div>
                                <div>
                                      <label>
                                        <p>用户名：<?php echo $arr["nickname"];?></p><i onclick="cookipost()" class="ui-btn3" style="color: #979797; float:right;">退出</i>
                                    </label>
                                </div>
                            </div>
                  </a>
 <?php
   if($row=DB::result_first("SELECT `ID`,`KM`,`UDID`,`OPENID`,`Level`,`Activation`,`TimeStamp`,`CreateStamp` FROM `".DCRM_CON_PREFIX."Activation` WHERE `OPENID`='".$_SESSION['openid']."' ORDER BY `Level` DESC limit 1" )){  
     
   ?>
<?php
          $ress = DB::query("SELECT `Level`,`CreateStamp` FROM `".DCRM_CON_PREFIX."Activation` WHERE `Openid`='".$_SESSION['openid']."'ORDER BY `Level` DESC limit 1");
		foreach($ress as $res){       
?>         
                  <a>
                        <img class="icon" src="<?php echo(SITE_URL); ?>icon/<?php 
                         if($res['Level']=='2'){ echo 'lv1.png';}
                         if($res['Level']=='3'){echo 'lv2.png';}  
                         if($res['Level']=='4'){echo 'lv3.png';}       
                         if($res['Level']=='5'){echo 'lv4.png';}      
                         if($res['Level']=='6'){echo 'lv5.png';}       
                         if($res['Level']=='7'){echo 'lv6.png';}
                         ?>" style="border-radius: 50%;box-shadow:0 0 1px #AAA;padding:1px;margin-right: 1px;">
                            <div>
                                <div>
                                      <label>
                                        <p>会员等级：
                                          <?php 
                    if($res['Level']=='2'){ echo '蓝苹果会员';}
                    if($res['Level']=='3'){echo '铜苹果会员';}  
                    if($res['Level']=='4'){echo '银苹果会员';}       
                    if($res['Level']=='5'){echo '金苹果会员';}      
                    if($res['Level']=='6'){echo '白金尊贵会员';}       
                    if($res['Level']=='7'){echo '系统管理员';}     
                                          ?></p>
                                     <?php
function diffBetweenTwoDays ($day1, $day2)
{
  $second1 = strtotime($day1);
  $second2 = strtotime($day2);
    
  if ($second1 < $second2) {
    $tmp = $second2;
    $second2 = $second1;
    $second1 = $tmp;
  }
  return ($second1 - $second2) / 86400;
}
$time = strtotime($res['CreateStamp']);
$date=date("Y-m-d"); 
$day1 = $date;
$day2 = (date("Y-m-d", $time));
$diff = diffBetweenTwoDays($day1, $day2);                            
?> 
                                    </label>
                                </div>
                          </div> 
                    </a>
               <div>
				<p  style="text-align:left">◉今日是您加入会员第<?php echo($diff); ?>天，感谢您的加入！</p>
			</div>
<?php
                              }
 } else {
?>            
                    <a>
                        <img class="icon" src="<?php echo(SITE_URL); ?>icon/gly.png" style="border-radius: 50%;box-shadow:0 0 1px #AAA;padding:1px;margin-right: 1px;">
                            <div>
                                <div>
                                      <label>
                                        <p>会员等级：小苹果会员</p>
                                    </label>
                                </div>
                          </div> 
                    </a> 

<?php  
 }
?>    
                      <a>           
                        <img class="icon" src="./icon/user.png">
                            <div>
                                <div>
                                    <label>
                                        <p>升级会员组</p><i onclick="cookipost1()" class="ui-btn3" style="color: #979797; float:right;">前往升级</i>
                                    </label>
                                </div>
                            </div>
                    </a>
              		<a class="theme-login" href="javascript:;">
					<img class="icon" src="icon/7.png">
					<div>
						<div>
							<label>
								<p id="source-name">一键反馈</p>
							</label>
						</div>
					</div>
				   </a>
			</fieldset>
<div class="theme-popover">
     <div class="theme-poptit">
	      提交反馈意见
          <a href="javascript:;" title="关闭" class="close">×</a>
     </div>
     <div class="theme-popbod dform">
           <form class="theme-signin" name="loginform" action="" method="get">
                <ol>
                     <li><strong>反馈标题：</strong><input class="ipt" type="text" name="Title" size="20" /></li>
                     <li><strong>反馈内容：</strong><input class="ipts" type="text" placeholder="请输入您的问题" name="content" size="20"></li>
                     <li><input class="btn2 btn-primary" type="submit" name="submit" value=" 提交 " /></li>
                </ol>
           </form>
     </div>
</div>
<div class="theme-popover-mask"></div>
<?php
function kmtype2(){ 

$appid=AUTOFILL_WXAPPID;
$secret=AUTOFILL_WXKEYID;
$template_id=AUTOFILL_GDOPENID;
$openid=AUTOFILL_WXOPENID;
$ac = file_get_contents('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$appid.'&secret='.$secret);
$wxt = json_decode($ac,true);
$url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $wxt['access_token'];//access_token改成你的有效值
$time=date("Y-m-d h:i:s");   
$usertjgd=$arr['nickname'];
$ress = DB::query("SELECT * FROM `".DCRM_CON_PREFIX."User` WHERE `Openid`='".$_SESSION['openid']."'");
foreach($ress as $res){       
$nameuser=$res['User'];
  $useropen=$_SESSION['openid'];
$Feedback=$_GET['content'];  
$orderid=date('YmdHis') . rand(1000,9999);  
}
$data = array(
    'first' => array(
        'value' => '新工单提醒！',
        'color' => '#FF0000'
    ),
    'keyword1' => array(
        'value' => 'MYY-'.$orderid,
        'color' => '#FF0000'
    ),
    'keyword2' => array(
        'value' => '用户'.$nameuser.'提交了一个新的工单：'.$Feedback,
        'color' => '#FF0000'
    ),
    'keyword4' => array(
        'value' => $time,
        'color' => '#FF0000'
    ),  
    'remark' => array(
        'value' => '待处理任务！',
        'color' => '#FF0000'
    )
);
$template_msg=array('touser'=>$openid,'template_id'=>$template_id,'topcolor'=>'#FF0000','url' => 'http://mycydia.vip/wxfkhf.php?id='.$useropen,'data'=>$data); 
$curl = curl_init($url);
$header = array();
$header[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
// 不输出header头信息
curl_setopt($curl, CURLOPT_HEADER, 0);
// 伪装浏览器
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36');
// 保存到字符串而不是输出
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// post数据
curl_setopt($curl, CURLOPT_POST, 1);
// 请求数据
curl_setopt($curl,CURLOPT_POSTFIELDS,json_encode($template_msg));
$response = curl_exec($curl);
curl_close($curl);  
 //echo $response;      
} 
?>  
 <?php 
if(isset($_GET['Title'])||isset($_GET['content'])){  
if($_GET['Title']==null or $_GET['content']==null){
  echo "<script> alert('工单内容不能为空');</script>"; 
}else{ 
$OPENID=$_SESSION['openid'];  
$content=$_GET["content"];
$Title=$_GET['Title'];  
$date=date("Y-m-d h:i:s"); 

if($row=DB::result_first("SELECT ID,UserOpenID,Title,Feedback,Reply,SubmissTime,RecoveryTime,KnotOrder FROM `".DCRM_CON_PREFIX."Worklist` WHERE `KnotOrder`<'1' and `UserOpenID`='".$_SESSION['openid']."'")){   
 echo "<script> alert('您当前有工单尚未结单处理！请勿重复提交！');parent.location.href='".$_SESSION["preUrl"]."'; </script>"; 
}else{   
 
$query = DB::query("INSERT INTO `".DCRM_CON_PREFIX."Worklist` (ID,UserOpenID,Title,Feedback,Reply,SubmissTime,RecoveryTime,KnotOrder) VALUES ('','$OPENID','$Title','$content','','$date','$date','0')");
  echo "<script> alert('您的反馈我们已经收到，我们将尽快与您回复！');parent.location.href='".$_SESSION["preUrl"]."';</script>"; 
  $fkwx=kmtype2();
}
}
}
?>       
      <script language="javascript">
    function cookipost(){
      $.get("./qqlogin/qqlogout.php", function(result){
    	location.reload();
  	  });  
	}
  </script>  
  <script language="javascript">
    function cookipost1(){
    	parent.location.href='./userjh.php'; 
	}
  </script>   

           
<label class="source"><p>用户反馈内容</p></label>   
     
 <?php 
function news($pageNum = 1, $pageSize = 3)
{
    $array = array();
    $coon = mysqli_connect("localhost", "s7420423", "kui203061");
    mysqli_select_db($coon, "s7420423");
    mysqli_set_charset($coon, "utf8");
    // limit为约束显示多少条信息，后面有两个参数，第一个为从第几个开始，第二个为长度
    $rs = "SELECT ID,UserOpenID,Title,Feedback,Reply,SubmissTime,RecoveryTime,KnotOrder FROM `".DCRM_CON_PREFIX."Worklist` WHERE  `UserOpenID`='".$_SESSION['openid']."' ORDER BY `KnotOrder` ASC limit " . (($pageNum - 1) * $pageSize) . "," . $pageSize;

    $r = mysqli_query($coon, $rs);
    while ($obj = mysqli_fetch_object($r)) {
        $array[] = $obj;
    }

    return $array;
}
  function allNews()
{
    $coon = mysqli_connect("localhost", "s7420423", "kui203061");
    mysqli_select_db($coon, "s7420423");
    mysqli_set_charset($coon, "utf8");
    $rs = "select count(*) num FROM `".DCRM_CON_PREFIX."Worklist` WHERE  `UserOpenID`='".$_SESSION['openid']."'"; //可以显示出总页数
    $r = mysqli_query($coon, $rs);
    $obj = mysqli_fetch_object($r);

    return $obj->num;
}
?> 
<?php
   $allNum = allNews();
   $pageSize = 3; //约定每页显示的信息条数
   $pageNum = empty($_GET["pageNum"])?1:$_GET["pageNum"];
   $endPage = ceil($allNum/$pageSize); //总页数
   $array = news($pageNum,$pageSize);
?>       

         
<?php  
    foreach($array as $key=>$values){ 
 
?>
<block class="box1" style="background-color: #FFFFFF;">
<span style="color:#E53333;font-size:15px;">反馈标题：<?php echo($values->Title); ?></span><br>
<span style="color:#E53333;font-size:15px;">反馈内容：<?php echo($values->Feedback); ?></span><br>
<span style="color:#E53333;font-size:15px;">提交时间：<?php echo($values->SubmissTime); ?></span><br>
<span style="color:#E53333;font-size:15px;">当前状态：<?php echo($values->Reply); ?>&nbsp;&nbsp;<?php if(($values->KnotOrder)=='0'){ echo '待回复';}if(($values->KnotOrder)=='1'){ echo '已回复';}if(($values->KnotOrder)=='2'){echo '已结单';}?></span><br>    
</block>  
<?php
   }
?>             

<?php
  if($endPage > 1){
?>            
 <div class="pager" >
<div class="page_list" >
<div class="pagin">

<a href="MobileWork.php?pageNum=1">首页</a>  
<a href="MobileWork.php?pageNum=<?php echo $pageNum==1?1:($pageNum-1)?>">上一页</a> 
<span class='current'><?php echo $pageNum ?>/<?php echo ($endPage)?></span>
<a href="MobileWork.php?pageNum=<?php echo $pageNum==$endPage ?$endPage:($pageNum+1)?>">下一页</a>
<a href="MobileWork.php?pageNum=<?php echo ($endPage) ?>">尾页</a>
</div></div></div>   
<?php
 }
 }
?>      
 <?php 
if(isset($_SESSION["accesstoken"]) || isset($_SESSION["openid"])) {      
$User=$arr["nickname"];
$Logo=$arr['figureurl_qq_2'];
$Openid=$_SESSION["openid"];
$date=date("Y-m-d h:i:s");
$ip = ($ip) ? $ip : $_SERVER["REMOTE_ADDR"];   
if($row=DB::result_first("SELECT * FROM `".DCRM_CON_PREFIX."User` WHERE `Openid`='".$Openid."'" )){    
  $sql = DB::query("UPDATE `".DCRM_CON_PREFIX."User` SET `Logo` = '".$Logo."', `User` = '".$User."',`IP` = '".$ip."' WHERE `Openid`='".$Openid."'");
} else {  
  $query = DB::query("INSERT INTO `".DCRM_CON_PREFIX."User` (ID,User,Logo,Openid,Packages,Collection,TimeStamp,IP) VALUES ('','$User','$Logo','$Openid','','','$date','$ip')");
}      
}
?> 
 	<fieldset class="box">
				<a>
					<div>
						<div>
						<span style="font-size:14px;color:#E53333;"><strong>说明:</strong></span>
						<span style="font-size:14px;color:#303130;">请前往<?php echo(AUTOFILL_SEO); ?>开始您的收藏之旅吧！</span>
						</div>
					</div>
				</a>
			</fieldset>
      

			<fieldset class="source box">
				<a href="<?php echo(SITE_URL); ?>">
					<img class="icon" src="<?php echo(SITE_URL); ?>CydiaIcon.png" />
					<div>
						<div>
							<label>
								<p id="source-name">
									<?php echo($release_origin); ?>
								</p>
							</label>
						</div>
					</div>
				</a>
				<div class="source-description" >
					<p><marquee scrollAmount=<?php echo(AUTOFILL_DESCRIPTION3); ?> width="98%"><span style="color:<?php echo(AUTOFILL_DESCRIPTION2); ?>"><?php echo( defined("AUTOFILL_DESCRIPTION1") ? htmlspecialchars(stripslashes(AUTOFILL_DESCRIPTION1)) : $null ); ?></marquee></p>
				</div>
			</fieldset>
       <footer id="footer">
<?php
          
       if($row=DB::result_first("SELECT `User`,`Logo`,`Openid`,`Packages`,`TimeStamp` FROM `apt_User` WHERE `Openid`='".$_SESSION['openid']."'" )){  
?> 
<?php         
       $Openids = DB::fetch_all("SELECT `User`,`Logo`,`Openid`,`Packages`,`TimeStamp` FROM `apt_User` WHERE `Openid`='".$_SESSION['openid']."'");
		foreach($Openids as $Openid){ 
?>    
           
           <p> <span>登录时间： <?php echo($Openid['TimeStamp']) ?></span></p>
<?php  
 } 
?>          
<?php            
 }else{ 
         
$date=date("Y-m-d h:i:s");         
?>
			
				<p>
<span>在线状态：您未登录</span><br>
<span>当前时间： <?php echo($date) ?></span>  
				</p>
			         
<?php  
 } 
?>      
           </footer> 
			<footer id="footer">
				<p>
					<span class="source-name">Copyright © 2015 cydiavip </span>·
					<span id="section">版权所有 &copy; 2015-2018</span>
				</p>
			</footer>
<?php
if(isset($_GET["UserOpenID"])){          
$UserOpenID=$_GET["UserOpenID"];
$Package=$_GET["Package"];
$PackageID=$_GET["PackageID"];  
$Name=$_GET["Name"];
$Icon=$_GET["Icon"];
$Collection=$_GET["Collection"];  
$date=date("Y-m-d h:i:s");     
$servername = "localhost";
$username = "bbs";
$password = "12345678";
$dbname = "bbs";    
$conn2 = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
} 
 $ip = ($ip) ? $ip : $_SERVER["REMOTE_ADDR"];  
$date=date("Y-m-d h:i:s");   
 

   
$conn = @mysql_connect("localhost","bbs","12345678");
if (!$conn){
    die("连接数据库失败：" . mysql_error());
}
mysql_select_db("bbs", $conn);
mysql_query("set character set 'utf8'");   // PHP 文件为 utf-8 格式时使用
$sql = "SELECT `ID`,`UserOpenID`,`Package`,`Name`,`Icon`,`TimeStamp` FROM `apt_Collection` WHERE `UserOpenID`='".$_GET["UserOpenID"]."' AND `Package`='".$_GET["Package"]."' ";
                //得到查询结果数据集
$result = mysql_query($sql);
//循环从数据集取出数据
if ( $row = mysql_fetch_array($result) ){

//echo "数据存在";

}else{  
$sql2 = "INSERT INTO apt_Collection(ID,UserOpenID,Package,PackageID,Name,Icon,TimeStamp) VALUES ('','$UserOpenID','$Package','$PackageID','$Name','$Icon','$date')";  
if ($conn2->query($sql2) === TRUE) {
//echo "收藏成功";
} else {
//echo "失败";
}

} 
  }
?>    
<?php
if(isset($_GET["UserOpenID2"])){          
$UserOpenID=$_GET["UserOpenID2"];
$Package=$_GET["Package"];
$PackageID=$_GET["PackageID"];  
$Name=$_GET["Name"];
$Icon=$_GET["Icon"];
$Collection=$_GET["Collection"];  
$date=date("Y-m-d h:i:s");     
$servername = "localhost";
$username = "bbs";
$password = "12345678";
$dbname = "bbs";    
$conn2 = new mysqli($servername, $username, $password, $dbname);
// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
} 
 $ip = ($ip) ? $ip : $_SERVER["REMOTE_ADDR"];  
$date=date("Y-m-d h:i:s");   
 

   
$conn = @mysql_connect("localhost","bbs","12345678");
if (!$conn){
    die("连接数据库失败：" . mysql_error());
}
mysql_select_db("bbs", $conn);
mysql_query("set character set 'utf8'");   // PHP 文件为 utf-8 格式时使用
$sql = "SELECT `ID`,`UserOpenID`,`Package`,`Name`,`Icon`,`TimeStamp` FROM `apt_Collection` WHERE `UserOpenID`='".$_GET["UserOpenID2"]."' AND `Package`='".$_GET["Package"]."' ";
                //得到查询结果数据集
$result = mysql_query($sql);
//循环从数据集取出数据
if ( $row = mysql_fetch_array($result) ){

$sql2 = "DELETE FROM `apt_Collection` WHERE `UserOpenID`='".$_GET["UserOpenID2"]."' AND `Package`='".$_GET["Package"]."'";  
if ($conn2->query($sql2) === TRUE) {
//echo "收藏成功";
} else {
//echo "失败";
}

}else{  
$sql2 = "DELETE FROM `apt_Collection` WHERE `UserOpenID`='".$_GET["UserOpenID2"]."' AND `Package`='".$_GET["Package"]."'";  
if ($conn2->query($sql2) === TRUE) {
//echo "收藏成功";
} else {
//echo "失败";
}

} 
  }
?>    
     
      
      
      
      
      